<table cellspacing="0" class="b3333 main">
 <tbody><tr>
     <th align="center" class="b0230" style="width: 24px;"><?php echo image_tag('/backend.php/utils/imageText/width/20/height/130/x/6/y/5/font/13/background/gray/color/000000/text/'.'Nastavni časovi'); ?></th>
     <th align="center" class="b0230" style="width: 100px;"><?php echo image_tag('/backend.php/utils/imageText/width/20/height/130/x/6/y/18/font/13/background/gray/color/000000/text/'.'Polugodište'); ?></th>
     <?php
     $i = 0;
     $count = count($predmets);
     foreach($predmets as $predmet_id => $naziv)
     {
        if(++$i == $count){?>
          <th align="center" class="b0130"><?php echo image_tag('/backend.php/utils/imageText/width/20/height/90/x/6/y/5/font/13/background/gray/color/000000/text/'.$naziv); ?></th>
        <?php }
        else {?>
          <th align="center" class="b0230"><?php echo image_tag('/backend.php/utils/imageText/width/20/height/90/x/6/y/5/font/13/background/gray/color/000000/text/'.$naziv); ?></th>
     <?php } }?>
 </tr>

 <tr>
  <th align="center" class="b0230" rowspan="3"><?php echo image_tag('/backend.php/utils/imageText/width/20/height/90/x/6/y/10/font/13/background/gray/color/000000/text/'.'Planirano'); ?></th>
  <th align="center" class="b0220">Prvo</th>
  <?php
     $i = 0;
     $count = count($predmets);
     foreach($predmets as $predmet_id => $naziv)
     {
        if(++$i == $count){?>
          <td align="center" class="b0120"><?php echo '' ?></td>
        <?php }
        else {?>
          <td align="center" class="b0220"><?php echo '' ?></td>
     <?php } }?>
 </tr>

  <tr>
  <th align="center" class="b0220">Drugo</th>
  <?php
     $i = 0;
     $count = count($predmets);
     foreach($predmets as $predmet_id => $naziv)
     {
        if(++$i == $count){?>
          <td align="center" class="b0120"><?php echo '' ?></td>
        <?php }
        else {?>
          <td align="center" class="b0220"><?php echo '' ?></td>
     <?php } }?>
 </tr>

 <tr>
  <th align="center" class="b0230">Ukupno</th>
  <?php
     $i = 0;
     $count = count($predmets);
     foreach($predmets as $predmet_id => $naziv)
     {
        if(++$i == $count){?>
          <td align="center" class="b0130"><?php echo '' ?></td>
        <?php }
        else {?>
          <td align="center" class="b0230"><?php echo '' ?></td>
     <?php } }?>
 </tr>

 <tr>
  <th align="center" class="b0230" rowspan="3"><?php echo image_tag('/backend.php/utils/imageText/width/20/height/90/x/6/y/10/font/13/background/gray/color/000000/text/'.'Održano'); ?></th>
  <th align="center" class="b0220">Prvo</th>
  <?php
     $i = 0;
     $count = count($predmets);
     foreach($predmets as $predmet_id => $naziv)
     {
        if(++$i == $count){?>
          <td align="center" class="b0120"><?php echo isset($cas_ps[$predmet_id]) ? $cas_ps[$predmet_id] : '' ?></td>
        <?php }
        else {?>
          <td align="center" class="b0220"><?php echo isset($cas_ps[$predmet_id]) ? $cas_ps[$predmet_id] : '' ?></td>
     <?php } }?>
 </tr>

 <tr>
  <th align="center" class="b0220">Drugo</th>
  <?php
     $i = 0;
     $count = count($predmets);
     foreach($predmets as $predmet_id => $naziv)
     {
        if(++$i == $count){?>
          <td align="center" class="b0120"><?php echo isset($cas_ds[$predmet_id]) ? $cas_ds[$predmet_id] : '' ?></td>
        <?php }
        else {?>
          <td align="center" class="b0220"><?php echo isset($cas_ds[$predmet_id]) ? $cas_ds[$predmet_id] : '' ?></td>
     <?php } }?>
 </tr>

 <tr>
  <th align="center" class="b0230">Ukupno</th>
  <?php
     $i = 0;
     $count = count($predmets);
     foreach($predmets as $predmet_id => $naziv)
     {
        if(++$i == $count){?>
          <td align="center" class="b0130"><?php echo (isset($cas_ps[$predmet_id]) or isset($cas_ds[$predmet_id])) ? (isset($cas_ps[$predmet_id]) ? $cas_ps[$predmet_id] : 0) + (isset($cas_ds[$predmet_id]) ? $cas_ds[$predmet_id] : 0) : '' ?></td>
        <?php }
        else {?>
          <td align="center" class="b0230"><?php echo (isset($cas_ps[$predmet_id]) or isset($cas_ds[$predmet_id])) ? ((isset($cas_ps[$predmet_id]) ? $cas_ps[$predmet_id] : 0) + (isset($cas_ds[$predmet_id]) ? $cas_ds[$predmet_id] : 0)) : '' ?></td>
     <?php } }?>
 </tr>

 <tr>
  <th align="center" class="b0200" rowspan="3"><?php echo image_tag('/backend.php/utils/imageText/width/20/height/90/x/6/y/2/font/13/background/gray/color/000000/text/'.'Neodržano'); ?></th>
  <th align="center" class="b0220">Prvo</th>
  <?php
     $i = 0;
     $count = count($predmets);
     foreach($predmets as $predmet_id => $naziv)
     {
        if(++$i == $count){?>
          <td align="center" class="b0120"><?php echo '' ?></td>
        <?php }
        else {?>
          <td align="center" class="b0220"><?php echo '' ?></td>
     <?php } }?>
 </tr>

 <tr>
  <th align="center" class="b0220">Drugo</th>
  <?php
     $i = 0;
     $count = count($predmets);
     foreach($predmets as $predmet_id => $naziv)
     {
        if(++$i == $count){?>
          <td align="center" class="b0120"><?php echo '' ?></td>
        <?php }
        else {?>
          <td align="center" class="b0220"><?php echo '' ?></td>
     <?php } }?>
 </tr>

 <tr>
  <th align="center" class="b0200">Ukupno</th>
  <?php
     $i = 0;
     $count = count($predmets);
     foreach($predmets as $predmet_id => $naziv)
     {
        if(++$i == $count){?>
          <td align="center" class="b0100"><?php echo '' ?></td>
        <?php }
        else {?>
          <td align="center" class="b0200"><?php echo '' ?></td>
     <?php } }?>
 </tr>



</tbody></table>